package com.happybluefin.tapburstfree.window;

import com.happybluefin.tapburstfree.R;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.widget.ImageView;

public class LogoWindow extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        Log.d(TAG, "onCreate() start");

        setContentView(R.layout.logowindow);

        mImageViewLogo = (ImageView)findViewById(R.id.imageViewLogo);

        mAnimAlphaShow.setDuration(ANIM_TIME);
        mAnimAlphaShow.setAnimationListener(new AnimationListener() {
            @Override
            public void onAnimationEnd(Animation animation) {
//              mImageViewLogo.setAlpha(1);
                mImageViewLogo.startAnimation(mAnimAlphaHide);
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
            }

            @Override
            public void onAnimationStart(Animation animation) {
            }
        });

        mAnimAlphaHide.setDuration(ANIM_TIME);
        mAnimAlphaHide.setAnimationListener(new AnimationListener() {
            @Override
            public void onAnimationEnd(Animation animation) {
                mImageViewLogo.setAlpha(0);
                _startTapBurstFreeWindow();
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
            }

            @Override
            public void onAnimationStart(Animation animation) {
            }
        });

//        mImageViewLogo.setAnimation(mAnimAlphaShow);
        mImageViewLogo.startAnimation(mAnimAlphaShow);
        
        Log.d(TAG, "onCreate() end");
    }
    

    @Override
    public void onDestroy() {
        super.onDestroy();
        Log.d(TAG, "onDestroy() start");
        Log.d(TAG, "onDestroy() end");
    }

    private void _startTapBurstFreeWindow() {
        Log.d(TAG, "_startTapBurstFreeWindow() start");

        Intent intent = new Intent(LogoWindow.this, TapBurstFreeWindow.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        this.startActivity(intent);
        overridePendingTransition(0, 0);

        this.finish();
        overridePendingTransition(0, 0);

        Log.d(TAG, "_startTapBurstFreeWindow() end");
    }

    private ImageView mImageViewLogo = null;
    private AlphaAnimation mAnimAlphaShow = new AlphaAnimation(0.0f, 1.0f);
    private AlphaAnimation mAnimAlphaHide = new AlphaAnimation(1.0f, 0.0f);
    
    private static final int ANIM_TIME = 1500;
    private static final String TAG = "LogoWindow";
}